package ParamParser;

my $count = 0;

my %settings;

###############################################################
# sub: openParams
sub getSettings { # ($paramFilename)

	my ($self, $file) = @_;
	
	die "Can't find file $file"
	  unless -f $file;
	    
	my $count = 0;
	
	my $parser = new XML::Parser(ErrorContext => 2);
	
	$parser->setHandlers(
							Char => \&charHandler,
							Start => \&startHandler,
							Default => \&defaultHandler);
	
	$parser->parsefile($file);

}

sub charHandler {
	my ($p, $string) = @_;
	$string =~ s/\s//g;
	if($string ne "") {
		print " $string";
	}
}

sub startHandler {
	my ($p, $element, $attrib, $invalue) = @_;
	if($element ne "settings") { print "\n$element "; }
	if($attrib ne "") {
		$attrib =~ s/\s//g;
		my $ename = $element . $attrib;	
		$settings{$ename} = $invalue;
		print "$attrib $settings{$ename}";
	}
}

sub defaultHandler {}

return 1;
